package com.skydroid.h30

import android.Manifest
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.RadioGroup
import androidx.core.app.ActivityCompat

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        requestPermissions()
        initView()
    }


    private fun initView(){

        var viewDecode = findViewById(R.id.view_decode) as? RadioGroup
        findViewById<View>(R.id.btn_player_rtsp).setOnClickListener {
            when(viewDecode?.checkedRadioButtonId){
                R.id.btn_soft->{
                    VideoActivity.start(this@MainActivity, 0)
                }
                R.id.btn_hardware->{
                    VideoActivity.start(this@MainActivity, 1)
                }
            }

        }

        findViewById<View>(R.id.btn_sky_uart).setOnClickListener {
            SkyDataActivity.start(this@MainActivity)
        }

        findViewById<View>(R.id.btn_rc_uart).setOnClickListener {
            RCDataActivity.start(this@MainActivity)
        }
        findViewById<View>(R.id.btn_rocker).setOnClickListener {
            RockerActivity.start(this@MainActivity)
        }
        findViewById<View>(R.id.btn_signal).setOnClickListener {
            SignalDisplayActivity.start(this@MainActivity)
        }
    }

    private fun requestPermissions() {
        ActivityCompat.requestPermissions(
            this, arrayOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE
            ), 0
        )
    }
}